package com.hs.tomcat.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

/**
 * @Author: hs
 * @Description: http://192.168.126.137:8080/tomcat.jvm/helloJConsole?len=50
 * http://192.168.126.137:8080/tomcat-war-0.0.1-SNAPSHOT/tomcat.jvm/helloJConsole?len=50
 * @Date: Create in 10:05 2019/5/20
 */
@RestController
@RequestMapping("/tomcat.jvm/")
public class TomcatJVMController {

    @GetMapping(value = "helloJConsole")
    public String queryProductByUnique(Integer len) {
        Random random = new Random();
        List<Integer> list = new ArrayList<>();
        for(int i=0;i<len;i++){
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            list.add(random.nextInt());
        }
        Object[] array = list.toArray();
        Arrays.sort(array);
        for(Object o : array){
            System.out.println(o);
        }
        return "ok";
    }
}
